{php include wl_template('common/header');}
<style type='text/css'>
       .trbody td {text-align: center; vertical-align:top;border-left:1px solid #ccc; border-bottom: 1px solid #ddd;}
</style>
<style>
	.order-rank img{width:16px; height:16px;}
	.js-remark,.js-admin-remark{word-break:break-all; overflow:hidden; background: #FDEEEE;color: #ED5050;padding: 5px 10px;}
	td.goods-info{position:relative; padding-left:60px;}
	.goods-info .img{position:absolute;top:50%; margin-top:-25px; background: url({IMAGE_LOADING}) center center no-repeat; width:50px;height:50px; }
	.goods-info span {white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;}
	.status-text{cursor:pointer;}
	.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {border-top: 1px solid rgba(221, 221, 221, 0);word-break:break-all;}
</style>

{if $op == 'cabinet_admin'}
<div class="main">
    <div class="panel panel-info">
	    <div class="panel-heading">筛选</div>
	    <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="vittor_homework_cabinet" />
                <input type="hidden" name="do" value="bind" />
                <input type="hidden" name="ac" value="bind" />
                <input type="hidden" name="op" value="cabinet_admin"/>
                <input type="hidden" name="status" value="{$status}"/>
				<div class="form-group">
                    <label class="col-md-4 col-lg-2 control-label">设备信息ID</label>
					<div class="col-md-4">
					<select name="device_info_id" class="form-control" id="first-data" onchange="">
						<option value="">--所有--</option>
						{loop $device_info_select $key $row}
						<option value="{$row['device_info_id']}" {if $_GPC['device_info_id']==$row['device_info_id']}selected="selected"{/if}>{$row['device_info_id']}</option>
						{/loop}
					</select>
					</div>
                </div>
                <div class="form-group">
                        <div class="col-sm-4 col-lg-2" style="text-align:right;"><button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        </div>
                </div>
	
            </form>
				<div class="col-lg-2">
				</div>

	   		 <!--<div class="form-group">
                <label class="col-md-4 col-lg-1 control-label" style="text-align: right;padding-right: 30px;">数据统计</label>
				<a href='{php echo web_url('order/data/', array('status' => $status))}'><button class="btn btn-danger"><i class="fa fa-align-justify"></i> 数据统计</button></a>
	   		 </div>-->
	    </div>
	</div>
	<div class="order-list">
		<div class="panel-body table-responsive collapse in" id="order-template-item-4" style="padding: 0;">
			<table class="table table-bordered">
				<thead style="background-color: #FFFFFF;">
					<tr>
                        <th style="width:70px;">设备信息ID</th>
						<th style="width:120px; text-align:center;">设备ID</th>
						<th style="width:60px; text-align:center;">在线状态</th>
                        <th style="width:80px; text-align:center;">设备名称</th>
                        <th style="width:30px; text-align:center;">柜门数</th>
						<th style="width:80px; text-align:center;">openid</th>
						<th style="width:80px; text-align:center;">姓名</th>
						<th style="width:80px; text-align:center;">角色</th>						
						<th style="width:120px; text-align:center;">二维码更新时间</th>
						<th style="width:80px; text-align:center;">备注</th>						
					</tr>
				</thead>
				
			</table>
		</div>
		{loop $device $key $value}
            {loop $value['openid'] $k $val}
            <div class="panel panel-default">
                <div class="panel-heading clearfix" style="padding: 10px 15px;">
                    <div class="pull-right">
                        <button type="button" class="update_qr" info_id="{$value['device_info_id']}">更新二维码</button>
                        {if $value['time']!=''}
                        <button type="button" class="show_qr" info_id="{$value['device_info_id']}" random="{$value['random']}">显示二维码</button>
                        {/if}
                    </div>
                </div>
                <div class="panel-body table-responsive" style="padding: 0px;">
                    <table class="table table-bordered table-data">
                    <thead style="background-color: #FFFFFF;">
                        <tr>
                            <th style="width:70px;">{$value['device_info_id']}</th>
                            <th style="width:120px; text-align:center;">{$value['device_id']}</th>
                            <th style="width:60px; text-align:center;">{if $value['is_online']==0 }离线{/if}{if $value['is_online']==1 }在线{/if}</th>
                            <th style="width:80px; text-align:center;">{$value['device_name']}</th>
                            <th style="width:30px; text-align:center;">{$value['door_num']}</th>                            
                            <th style="width:80px; text-align:center;">{$value['openid'][$k]}</th>
                            <th style="width:80px; text-align:center;">{$value['name'][$k]}</th>
                            <th style="width:80px; text-align:center;">{$rolenamearray[$value['role'][$k]]}</th>						
                            <th style="width:120px; text-align:center;"><?php if($value['time']=='') echo '暂未更新'; else echo date("Y-m-d H:i:s", $value['time']);?></th>
                            <th style="width:80px; text-align:center;">{$value['remark']}</th>
                        </tr>
                    </thead>
                    
                   </table>
                </div>
                
            </div>
            {/loop}
		{/loop}
	</div>
	{$pager}
</div>
<div class="modal in" id="order-remark-container" >	
	<div class="modal-dialog">		
		<div class="modal-content">			
			<div class="modal-header">				
				<button type="button" class="close"><span id="close">×</span></button>				
				<h4 class="modal-title">卖家备注</h4>			
			</div>			
			<div class="modal-body">				
				<div id="qrcode"> </div>	
			</div>					
		</div>	
	</div>
</div>

{/if}
<script type="text/javascript">
require(['daterangepicker'], function($){
	$('.daterange').on('apply.daterangepicker', function(ev, picker) {
		$('#form1')[0].submit();
	});
});
	$(function(){	
		// 显示二维码
		$('.show_qr').click(function() {
			var info_id = $(this).attr('info_id');
            var random = $(this).attr('random');
            $('#order-remark-container h4').text('设备信息ID：'+info_id);
            $("#qrcode").empty();
            new QRCode(document.getElementById('qrcode'), "{php echo app_url('scangenerate/scan/cabinet_admin');}"+'&info_id='+info_id+'&random='+random);
			$('#order-remark-container').show();
			$('.main').css("opacity","0.2");$('.nav').css("opacity","0.2");$('.big-menu').css("opacity","0.2");
		});
		$('.js-cancel,.close').click(function() {
			$('#order-remark-container').hide();
			$('.main').css("opacity","1");$('.nav').css("opacity","1");$('.big-menu').css("opacity","1");
		});
        //更新二维码
        $('.update_qr').click(function() {
			var info_id = $(this).attr('info_id');
            $.post("{php echo web_url('bind/bind/update_qrcode');}", { info_id : info_id}); 
            window.location="{php echo web_url('bind/bind/cabinet_admin');}&device_info_id="+info_id;            
		});
        
	});

</script>
{php include wl_template('common/footer');}